package com.langll.mcp.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class BaseEntityMetaObjectHandler implements MetaObjectHandler {

    /**
     * 定时任务执行 操作时 没有 user
     */
    private String operator = "System";
    @Override
    public void insertFill(MetaObject metaObject) {
//        this.strictInsertFill(metaObject,"createTime", LocalDateTime.class,LocalDateTime.now());
//        this.strictInsertFill(metaObject,"updateTime",LocalDateTime.class,LocalDateTime.now());
//        if(SecurityContextHolder.getContext().getAuthentication() != null){
//            operator = SecurityContextHolder.getContext().getAuthentication().getName();
//        }
//        this.strictInsertFill(metaObject,"creator", String.class,operator);
//        this.strictInsertFill(metaObject,"modifier",String.class,operator);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
//        this.strictInsertFill(metaObject,"updateTime",LocalDateTime.class,LocalDateTime.now());
//        if(SecurityContextHolder.getContext().getAuthentication() != null){
//            operator = SecurityContextHolder.getContext().getAuthentication().getName();
//        }
//        this.strictInsertFill(metaObject,"modifier",String.class,operator);
    }
}
